package com.util;

import io.fabric8.kubernetes.api.model.*;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.*;
import io.fabric8.kubernetes.client.ConfigBuilder;
import org.slf4j.*;

import java.util.List;


public class ListNameSpace {

    private static final Logger logger = LoggerFactory.getLogger(com.util.ListNameSpace.class);

    public static void main(String[] args)  {
        Config config = new ConfigBuilder().build();

        try (final KubernetesClient client = new DefaultKubernetesClient(config)) {
            NamespaceList nsl = client.namespaces().list();
            //System.out.print(nsl);
            List<Namespace> items = nsl.getItems();
            for (Namespace item : items) {
            System.out.print(item.getMetadata().getName() + '\n');
            }
            //logger.info(storageClassList.toString());

        } catch (KubernetesClientException e) {
            logger.error(e.getMessage(), e);
        }

    }

}